package swind.web.dao.imp;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import swind.web.dao.ISubjectDao;
import swind.web.dao.base.BaseHibernateDAO;
import swind.web.entities.ExamSubject;
import swind.web.vo.SubjectVo;

@Repository("subjectDaoImp")
public class SubjectDaoImp extends BaseHibernateDAO<ExamSubject> implements ISubjectDao{
	
	
	@SuppressWarnings("unchecked")
	@Override
	public List<SubjectVo> getAllSubject(){
		
		Query query=this.createQuery("select new swind.web.vo.SubjectVo(es.subId,es.name,es.description,es.testCount,es.totalTime,es.totalScore,es.status)  from ExamSubject es");
	
		return (List<SubjectVo>)query.list();
	}
	
	@Override
	public SubjectVo getSubjectById(int id){
		Query query=this.createQuery("select new swind.web.vo.SubjectVo(es.subId,es.name,es.description,es.testCount,es.totalTime,es.totalScore,es.status)  from ExamSubject es where es.subId="+id);

		return (SubjectVo) query.list().get(0);
	}
	
	
}
